import { getAllAplications } from "@/api/systemcofig";
import { ref, onMounted } from "vue";
import { useAppStoreHook } from "@/store/modules/app";
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
import { useGlobal } from "@pureadmin/utils";

export function useList() {
  const productList = ref(); //大标题
  const smallList = ref([]); //小标题
  const dataLoading = ref(true);
  const { layoutTheme } = useDataThemeChange();
  const { $storage } = useGlobal<GlobalPropertiesApi>();

  const getCardListData = async () => {
    try {
      const userRoles = {
        userRoles: "教师"
      };
      const result = await getAllAplications(userRoles);
      productList.value = result.result;
    } catch (e) {
      console.log(e);
    } finally {
      setTimeout(() => {
        dataLoading.value = false;
      }, 500);
    }
  };

  onMounted(() => {
    getCardListData();

    layoutTheme.value.layout = "vertical";
    window.document.body.setAttribute("layout", "vertical");
    $storage.layout = {
      layout: "vertical",
      theme: layoutTheme.value.theme,
      darkMode: $storage.layout?.darkMode,
      sidebarStatus: $storage.layout?.sidebarStatus,
      epThemeColor: $storage.layout?.epThemeColor
    };
    useAppStoreHook().setLayout("vertical");
    //console.log("flash web....6666");
    //useAppStoreHook().setLayout("vertical");
  });
  return {
    productList,
    smallList,
    getCardListData
  };
}
